package io.renren.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.entity.FybxDetEntity;
import io.renren.service.FybxDetService;
import io.renren.utils.PageUtils;
import io.renren.utils.Query;
import io.renren.utils.R;


/**
 * 报销明细id
 * 
 * @author zhangheng
 * @email zh_123shmily@163.com
 * @date 2017-07-30 12:06:14
 */
@RestController
@RequestMapping("fybxdet")
public class FybxDetController {
	@Autowired
	private FybxDetService fybxDetService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<FybxDetEntity> fybxDetList = fybxDetService.queryList(query);
		int total = fybxDetService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(fybxDetList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{bxdetId}")
	public R info(@PathVariable("bxdetId") Integer bxdetId){
		FybxDetEntity fybxDet = fybxDetService.queryObject(bxdetId);
		
		return R.ok().put("fybxDet", fybxDet);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	public R save(@RequestBody FybxDetEntity fybxDet){
		fybxDetService.save(fybxDet);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	public R update(@RequestBody FybxDetEntity fybxDet){
		fybxDetService.update(fybxDet);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	public R delete(@RequestBody Integer[] bxdetIds){
		fybxDetService.deleteBatch(bxdetIds);
		
		return R.ok();
	}
	
}
